package com.hoki.zj.hrm.client;

import com.hoki.zj.hrm.doc.CourseDoc;
import com.hoki.zj.hrm.utils.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class CourseESClientFallbackFactory implements FallbackFactory<CourseESClient> {

    @Override
    public CourseESClient create(Throwable throwable) {
        return new CourseESClient() {
            @Override
            public AjaxResult save(CourseDoc courseDoc) {
                log.info("save error: {}", throwable.getMessage());
                return new AjaxResult().setSuccess(false).setMessage("课程发布异常!");
            }

            @Override
            public AjaxResult del(Long id) {
                log.info("delete error: {}", throwable.getMessage());
                return new AjaxResult().setSuccess(false).setMessage("课程下线异常!");
            }
        };
    }
}
